package com.gitee.feizns.explore.data_structure.tree.bs.easy;

/**
 * @author feizns
 * @since 2019/12/25
 */
public class InvertTree {

    public static void main(String[] args) {
        invertTree(create());
//        invertTree();
    }

    private static TreeNode create() {
        TreeNode tmp = new TreeNode(1);
        tmp.left = new TreeNode(2);
        tmp.right = new TreeNode(3);
        return tmp;
    }

    public static TreeNode invertTree(TreeNode root) {
        if ( root != null ) {
            TreeNode left = invertTree(root.left);
            TreeNode right = invertTree(root.right);
            root.right = left;
            root.left = right;
        }
        return root;
    }

}
